package com.zhongkun.datahome.service.domain;

import com.zhongkun.datahome.service.req.cmd.assets.DataAssetsCmd;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

/**
 * 数字资产对象 data_assets
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
/**
 * @description 数字资产表
 * @author huangjie
 * @date 2025-04-16
 */
@Data
public class DataAssets extends BaseEntity {
    @ApiModelProperty("资产展示范围，0不展示，1指定业主，2全部业主")
    private Integer showScope;

    @ApiModelProperty("分组类型ID")
    private Long groupTypeId;

    /**
     * @see com.zhongkun.datahome.service.constant.DataAssetsTypeEnum
     */
    @ApiModelProperty("资产类型")
    private String assetsType;

    @Length(max = 64, message = "资产标题长度不能超过{max}")
    @ApiModelProperty("资产标题")
    private String assetsTitle;
    
    @ApiModelProperty("资产内容")
    private String assetsText;
    
    @ApiModelProperty("资产状态，0已下架，1已上架")
    private Integer assetsStatus;

    public static DataAssets of(DataAssetsCmd cmd) {
        DataAssets dataAssets = new DataAssets();
        dataAssets.update(cmd);
        dataAssets.setAssetsStatus(1);   // 默认上架

        return dataAssets;
    }

    public void update(DataAssetsCmd cmd) {
        this.setShowScope(cmd.getShowScope());
        this.setGroupTypeId(cmd.getGroupTypeId());
        this.setAssetsType(cmd.getAssetsType());
        this.setAssetsTitle(cmd.getAssetsTitle());
        this.setAssetsText(cmd.getAssetsText());
        this.setAssetsStatus(cmd.getAssetsStatus());
    }
}